<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<title>report</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../css/report.css" />
	</head>
	<body>
		<div id="wrap">
			<div id="main">
				<div class="hp_input one">
					<span class="title">密码:</span>
					<input type="text" id="password" value="">
					</input>
				</div>
				<div class="hp_input two">
					<span class="title">再输一次:</span>
					<input type="text" id="repassword" value="">
					</input>
				</div>
				<button tapmode="buttonActive" class="button blue" id="comfirm" onclick="comfirm()">
					完成
				</button>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script type="text/javascript" src="../script/constants.js"></script>
	<script>
		var newUser = 1;
		apiready = function() {
			newUser = api.pageParam.newUser;
		};
		function comfirm() {
			
			var password = $api.byId('password').value;
			var repassword = $api.byId('repassword').value;
			
			if (!(password && $api.trimAll(password))) {
				api.alert({
					msg : '请输入密码!'
				});
				return;
			}
					
			if (!(repassword && $api.trimAll(repassword))) {
				api.alert({
					msg : '请再输一次!'
				});
				return;
			}		
			
			if(repassword != password){
				api.alert({
					msg : '两次输入的密码不一致!'
				});
				return;
			}
			
			api.ajax({
				url : USER_URL + "?cmd=addUser", 
				method : 'post',
				cache : false,
				timeout : 3000,
				data : {
					values : {
						phoneNumber : api.pageParam.phoneNumber,
						password : password
					}
				}
			}, function(ret, err) {
				if (ret) {
					if (ret.resultCode == RESULT_CODE_SUCCESS) {
						$api.toast('提示','注册成功',3000);
						api.closeToWin({name: 'login'});
					} else {
						api.alert({
							msg : ret.resultMessage
						});
					}
				} else {
					api.alert({
						msg : "网络或者服务器有问题!"
					});
				};
			});
		}
	</script>
</html>